/*
 * BinaryTree.h
 *
 *  Created on: 07/07/2012
 *      Author: marcio
 */

#ifndef BINARYTREE_H_
#define BINARYTREE_H_

typedef struct _binarynode{
	void* elem;
	struct _binarynode* right;
	struct _binarynode* left;
	int lvl;
}BinaryTreeNode;

typedef struct _tree{
	BinaryTreeNode* root;
	int (*f)(void*, void*);
	int height;
	int size;
}BinaryTree;

BinaryTreeNode* binarytreenode_newNode(void* elem);

int binarytreenode_addToRight(BinaryTreeNode* root, BinaryTreeNode* newnode);

int binarytreenode_addToLeft(BinaryTreeNode* root, BinaryTreeNode* newnode);

BinaryTree* binarytree_newBinaryTree(BinaryTreeNode* root, int (*choice)(void*, void*));

int tree_getSize(BinaryTree* b);

BinaryTreeNode* binarytree_getRoot(BinaryTree* b);

int binarytree_addNode(BinaryTree* b, BinaryTreeNode* newnode);

int binarytree_removeNode(BinaryTree* b, int (*test)(void*));

BinaryTreeNode** binarytree_BFS(BinaryTree* b, long* size);

BinaryTreeNode** binarytree_DFS(BinaryTree* b, long* size);

BinaryTreeNode** binarytree_BFSOnlyLeafs(BinaryTree* b, long* size);

BinaryTreeNode** binarytree_DFSOnlyLeafs(BinaryTree* b, long* size);

int binarytree_BFSModify(BinaryTree* b,int (f)(void*));

int binarytree_DFSModify(BinaryTree* b,int (f)(void*));

#endif /* BINARYTREE_H_ */
